#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int a[100];
int n,x;
void inmenu(void)
{
	char ch;
	system("cls");
	printf("\n");
	printf("  0 - THOAT \n");
	printf("  1 - NHAP MANG \n");
	printf("  2 - TIM KIEM\n");
	printf("  3 - SAP XEP \n");
	do {
		ch=getch();
		switch(ch)
		{
			case 48: exit(0);
			break;
			case 49: menunhap();
			break;
			case 50: menutimkiem();
			break;
			case 51: menusapxep();
			break;
		}
	} while (ch<48||ch>51);
}
void menunhap(void)
{
	system("cls");
	printf("\n");
	printf("  0 - quay lai\n");
	printf("  1 - nhap ngau nhien \n");
	printf("  2 - nhap bang tay\n");
	printf("  3 - xem mang vua nhap\n");
	char ch;
	do {
		ch=getch();
		switch(ch)
		{
			case 48: inmenu();
			break;
			case 49: nhapngaunhien();
			break;
			case 50: nhapbangtay();
			break;
			case 51: xemmang();
			break;
		}
	} while (ch<48||ch>50);
}
void menutimkiem(void)
{
	system("cls");
	printf("\n");
	printf("  0 - quay lai\n");
	printf("  1 - tuan tu \n");
	printf("  2 - nhi phan\n");
	char ch;
	do {
		ch=getch();
		switch(ch)
		{
			case 48: inmenu();
			break;
			case 49: exit(0);
			break;
			case 50: exit(0);
			break;
		}
	} while (ch<48||ch>50);
}
void menusapxep(void)
{
	system("cls");
	printf("\n");
	printf("  0 - quay lai\n");
	printf("  1 - noi bot \n");
	printf("  2 - doi cho truc tiep\n");
	printf("  3 - chon truc tiep\n");
	printf("  4 - chen tuan tu\n");
	char ch;
	do {
		ch=getch();
		switch(ch)
		{
			case 48: inmenu();
			break;
			case 49: exit(0);
			break;
			case 50: exit(0);
			break;
		}
	} while (ch<48||ch>50);
}
void nhapngaunhien(void)
{
	int i;
	srand(time(NULL));
	system("cls");
	printf("   moi ban nhap so phan tu cua mang \n");
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		a[i]=rand()%100;
	}
	//xuat mang ngau nhien 
	/*
	printf("mang ngau nhien vua tao la \n");
	for (i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	getch();*/
	menunhap();
}
void nhapbangtay(void)
{
	int i;
	system("cls");
	printf("   moi ban nhap so phan tu cua mang \n");
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		printf("a[%d]= ",i);
		scanf("%d",&a[i]);
	}
	//xuat mang ngau nhien 
	/*printf("mang ban vua nhap la \n");
	for (i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	getch();*/
	menunhap();
}
void xemmang(void)
{
	int i;
	system("cls");
	printf("mang ban vua nhap la \n");
	for (i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	getch();
	menunhap();
}
main()
{
	system("cls");
	inmenu();
}
